﻿using DapperExtensions;
using Nova_Common.Extend;
using Nova_DAL;
using Nova_MOD;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Nova_BLL
{
    public class TDelStorage_ListBll
    {
        TDelStorage_ListDal dal = new TDelStorage_ListDal();

        public List<TDelStorage_List> GetByStockNo(string stockNo)
        {
            var predicate = Predicates.Field<TDelStorage_List>(t => t.StockNo, Operator.Eq, stockNo);
            return dal.GetList(predicate);
        }

        public TDelStorage_List GetByStockNoAndMatCode(string stockNo,string matCode)
        {
            PredicateGroup predicate = new PredicateGroup()
            {
                Operator = GroupOperator.And,
                Predicates = new List<IPredicate>()
            };
            predicate.Predicates.Add(Predicates.Field<TDelStorage_List>(t => t.StockNo, Operator.Eq, stockNo));
            predicate.Predicates.Add(Predicates.Field<TDelStorage_List>(t => t.Mat_Code, Operator.Eq, matCode));
            return dal.GetByField(predicate);
        }

        public bool InsertEntity(TDelStorage_List entity)
        {
            return !dal.Insert(entity).IsEmpty();
        }

        public bool InsertEntityList(List<TDelStorage_List> list)
        {
            return dal.Insert(list);
        }

        public bool UpdateEntity(TDelStorage_List entity)
        {
            return dal.Update(entity);
        }

        public List<DelStorageListModel> GetDelStorageListModel(string stockNo)
        {
            return dal.GetDelStorageListModel(stockNo);
        }
    }
}
